package com.aabte.design2.structural.adapter;

/**
 * 适配器类让你能够将方钉放入圆孔中。它会对 RoundPeg 类进行扩展，以接收适
 * 配器对象作为圆钉。
 *
 * @author Daniel
 * @version 1.0
 * @date 2020/5/3
 */
public class SquarePegAdapter extends RoundPeg {

    private SquarePeg squarePeg;

    public SquarePegAdapter(SquarePeg squarePeg) {
        this.squarePeg = squarePeg;
    }

    @Override
    public int getRadius() {
        return (int) (squarePeg.getWidth() * Math.sqrt(2) / 2);
    }
}
